<?php 
include '../../../php/conn.php'; 
if ($con) {
	if ($_POST) {
		
		$STbname= $_POST['STbname'];
		$DTid= $_POST['DTid'];
		 $STTime = date('y-m-d H:I:S');
	 //查询是否添加过
//	 SELECT *
//FROM `subjectstable`
//WHERE STbname = '语文'
		$masql = "SELECT * FROM subjectstable WHERE STbname='$STbname'"; 
		$msy=mysql_query($masql); 
		if ($msy) {
			$mynamesql = mysql_num_rows($msy);
			if ($mynamesql==1) {
				 
				//已有该数据
				echo '{"status":"100"}';
				
			} else {
				 
				 //没有此数据时执行新增
				$sql = "INSERT INTO `subjectstable`(`STid`, `STbname`, `DTid`, `STTime`) VALUES (0,'$STbname',$DTid,'$STTime')";
				//执行
				$rs = mysql_query($sql);
				if ($rs) { 
					 //新增成功 
					 echo '{"status":"200"}';
				}else
					{
						//新增失败
				echo '{"status":"404"}';
					}
				
				
				
			} 

		} else {
			//sql语句错误
			echo '{"status":"501"}';
		}
	 
	}  
	
		if ($_GET) {
		
		$STbname= $_GET['STbname'];
		 $STTime = date('y-m-d H:I:S');
	 //查询是否添加过
//	 SELECT *
//FROM `subjectstable`
//WHERE STbname = '语文'
		$masql = "SELECT * FROM subjectstable WHERE STbname='$STbname'"; 
		$msy=mysql_query($masql); 
		if ($msy) {
			$mynamesql = mysql_num_rows($msy);
			if ($mynamesql == 1) { 
				$sql = "INSERT INTO `subjectstable`(`STid`, `STbname`, `STTime`) VALUES (0,'$STbname','$STTime')";
				//执行
				$rs = mysql_query($sql);
				if ($rs) { 
					 //新增成功 
					 echo '{"status":"200"}';
				}
			} else {
				//新增失败
				echo '{"status":"404"}';
			} 

		} else {
			//sql语句错误
			echo '{"status":"501"}';
		}
	 
	}  
}
//关闭数据库
mysql_close($con);
?>